/*
 * @Description:
 * @Version: 1.0
 * @Autor: lzc
 * @Date: 2021-11-16 10:33:01
 * @LastEditors: lzc
 * @LastEditTime: 2021-11-17 13:21:27
 */
/**
  ******************************************************************************
  * @file    FSM.h
  * @brief   This file contains all the function prototypes for
  *          the FSM.c file
  ******************************************************************************
  * @attention
  *
  * <h2><center>&copy; Copyright (c) 2021 STMicroelectronics.
  * All rights reserved.</center></h2>
  *
  * This software component is licensed by ST under BSD 3-Clause license,
  * the "License"; You may not use this file except in compliance with the
  * License. You may obtain a copy of the License at:
  *                        opensource.org/licenses/BSD-3-Clause
  *
  ******************************************************************************
  */
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __FSM_H__
#define __FSM_H__

#ifdef __cplusplus
extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include "main.h"

#ifdef __cplusplus
}
#endif


typedef enum
{
    state_1 = 1,
    state_2,
    state_3,
    state_4,
    state_5,
    state_6,
    state_7
}
State;

typedef enum
{
    event_1 = 1,
    event_2,
    event_3,
    event_4,
    event_5,
    event_6
} EventID;

typedef char (*Action)(const EventID *);

typedef struct
{
    State curState;         //当前状态
    EventID eventId;        //事件ID
    State nextState;        //下个状态
    Action  action;         //具体表现
    // void (*eventActFun)(void *);  /* 动作函数 */
}
StateTransform;


typedef struct
{
    State state;
    int transNum;
    StateTransform *transform;
} StateMachine;

typedef struct FSM_STRUCT
{
    EventID FSM_EventType;
} FSM_Struct_t;

extern StateTransform stateTran[];

int run(void) ;
void runStateMachine(StateMachine *pSM, const EventID evt);
#endif /* __FSM_H__ */

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
